package com.zbf.web;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zbf.dao.TestDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/6/18  10:57
 * 描述:
 */
@RestController
public class TestController {

    @Value("${server.port}")
    private String port;

    @Autowired
    TestDao testDao;

    @RequestMapping("getUserList")
    public Object getUserList(@RequestBody Map<String,Object> map) throws InterruptedException {

        System.out.println("============>"+port);

        if(map.get("pageNo").toString().equals("1")){
          Thread.sleep(10000);
        }


        if(map.get("pageNo").toString().equals("6")){
            throw new RuntimeException("超出了对应的页码");
        }


        PageHelper.startPage(Integer.valueOf(map.get("pageNo").toString()),Integer.valueOf(map.get("pageSize").toString()));

        List<Map<String, Object>> userList = testDao.getUserList(map);

        PageInfo<Map<String,Object>> pageInfo=new PageInfo<Map<String, Object>>(userList);

        return pageInfo;
    }

}
